﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AhpilyServer
{
    /// <summary>
    /// 客户端的连接池 作用 重新调用客户端的连接对象
    /// </summary>
   public class ClientPeerPool
    {
        private Queue<ClientPeer> clientPeersQueue; //创建队列
        /// <summary>
        /// 队列的最大容量
        /// </summary>
        /// <param name="capacity"></param>
        public ClientPeerPool(int capacity)
        {
            clientPeersQueue = new Queue<ClientPeer>(capacity);
        }
        /// <summary>
        /// 回收对象
        /// </summary>
        /// <param name="client"></param>
        public void Enqueue(ClientPeer client)
        {
            clientPeersQueue.Enqueue(client);

        }
        /// <summary>
        /// 取出对象
        /// </summary>
        /// <returns></returns>
        public ClientPeer Dequeue()
        {
            ClientPeer peer = clientPeersQueue.Dequeue();
            peer.id = null;
            return peer;
        }
    }
}
